package migrations

import (
	"time"

	"gorm.io/gorm"
)

func init() {
	AddMigration("alert_rules", func(tx *gorm.DB) error {
		type AlertRule struct {
			ID          string `gorm:"primaryKey"`
			TenantID    string `gorm:"index"`
			MetricName  string `gorm:"size:255"`
			Threshold   float64
			Condition   string `gorm:"size:10"`
			Duration    time.Duration
			NotifyUsers []string `gorm:"type:json"`
			CreatedAt   time.Time
			UpdatedAt   time.Time
		}
		return tx.AutoMigrate(&AlertRule{})
	})
}
